<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Create new event</title>
    </h:head>
    <h:body>
        <h:form id="eventDetails">
            <p:panel header="Event details">
                <h:panelGrid columns="2" columnClasses="rightAlign, leftAlign">

                    <p:outputLabel for="name" value="Name:"></p:outputLabel>
                    <p:inputText id="name"
                                 label="Name"
                                 required="true"
                                 value="#{createEventBean.event.name}">
                        <f:validateLength minimum="2" maximum="20"></f:validateLength>
                    </p:inputText>

                    <p:outputLabel for="description" value="Description:"></p:outputLabel>
                    <p:inputTextarea id="description"
                                     rows="3" cols="30" counter="display" 
                                     maxlength="140"
                                     value="#{createEventBean.event.description}"
                                     counterTemplate="{0} characters remaining."/>
                    <h:panelGroup></h:panelGroup>
                    <h:outputText id="display" />

                    <p:outputLabel for="type" value="Type:"></p:outputLabel>
                    <p:selectOneRadio id="type" required="true"
                                      value="#{createEventBean.event.type}">
                        <f:selectItems value="#{createEventBean.eventTypes}"/>
                    </p:selectOneRadio>

                    <p:outputLabel for="location" value="City:"></p:outputLabel>
                    <p:inputText id="location"
                                 label="Location"
                                 required="true"
                                 value="#{createEventBean.event.location}">
                        <f:validateLength maximum="30"></f:validateLength>
                    </p:inputText>

                    <p:outputLabel for="date" value="Date:" />
                    <p:calendar id="date" required="true" mindate="today"
                                value="#{createEventBean.event.eventDate}"/>

                    <p:outputLabel for="startingTime" value="Starting time:" />
                    <p:calendar id="startingTime" required="true" pattern="HH:mm a" timeOnly="true"
                                value="#{createEventBean.event.startingTime}"/>

                    <p:outputLabel for="endingTime" value="Ending time:" />
                    <p:calendar id="endingTime" required="true" pattern="HH:mm a" timeOnly="true"
                                value="#{createEventBean.event.endingTime}" />

                    <p:outputLabel for="guests" value="Guests:"></p:outputLabel>
                    <p:inputText id="guests"
                                 label="Guests"
                                 value="#{createEventBean.guests}">
                    </p:inputText>
                    <h:panelGroup></h:panelGroup>
                    <p:outputLabel value="Separate guests by comma"/>

                    <h:panelGroup></h:panelGroup>
                    <p:commandButton id="submit"
                                     update="@all"
                                     action="#{createEventBean.createEvent()}"
                                     value="Create event">
                    </p:commandButton>
                </h:panelGrid>
            </p:panel>
            <h:messages style="color: red"></h:messages>
        </h:form>
    </h:body>
</html>

